package com.yc.jpyy.mobile.controller;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yc.jpyy.base.bean.RestResponse;
import com.yc.jpyy.base.config.Config;
import com.yc.jpyy.base.controller.BaseController;
import com.yc.jpyy.mobile.dao.AdminDao;
import com.yc.jpyy.mobile.service.AdminService;

@Controller
@RequestMapping(value = "/admin")
public class GetTeacherCallList extends BaseController {
	@Autowired
	private AdminService adminService;

	@Autowired
	private AdminDao adminDao;
	private static Logger logger = LoggerFactory.getLogger(AdminLoginController.class);

	/**
	 * 获取教练通讯录
	 * 
	 * @param request
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	@SuppressWarnings("finally")
	@RequestMapping(value = "/getTeacherCallList", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
	public @ResponseBody String getTeacherCallList(HttpServletRequest request)
			throws UnsupportedEncodingException {

		RestResponse response = new RestResponse();
		request.setCharacterEncoding("UTF-8");

		try {
			//驾校ID
			String driverId = request.getParameter("driverId");
			String teacherName = request.getParameter("teacherName");
			if (driverId != null && !driverId.isEmpty() ) {
				Map<String, Object> valMap = new HashMap<String, Object>();
				valMap.put("driverId", driverId);
				valMap.put("teacherName", teacherName);
				valMap.put("imgUrl", Config.getImageAddress());
				// 获取教练通讯
				response = adminService.getTeacherCallList(valMap, response);
			} else {
				response.setErrorcode(1);
				response.setMessage("必填参数为空...");
			}
		} catch (Exception e) {
			logger.info("getTeacherCallList:" + e.toString());
			response.setReturnMsg(1, "登录失败！");
		} finally {
			return response.toJSON();
		}
	}

}
